' 
' Copyright (C) 2014 Infinity CCS Ltd (http://www.infinityccs.com/)
' Copyright (C) 2007 Sasa Coh <sasacoh@gmail.com>
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program.  If not, see <http://www.gnu.org/licenses/>. 
'/


Imports Infinity.pjsipNET.Common
Imports Infinity.pjsipNET.Common.CallState

Namespace CallControl.CallState

#Region "Connecting"
  ''' <summary>
  ''' Connecting states indicates outgoing call has been initiated and waiting for a response.
  ''' </summary>
  Friend Class Connecting
    Inherits IState

    Public Sub New(sm As CallMachine)
      MyBase.New(sm)
      Id = EStateId.CONNECTING
    End Sub

    Friend Overrides Sub OnEntry()
      _smref.Type = CallLog.ECallType.EDialed
    End Sub

    Friend Overrides Sub OnExit()

    End Sub

    Public Overrides Sub onReleased()
      _smref.ChangeState(EStateId.RELEASED)
    End Sub

    Public Overrides Sub onAlerting()
      _smref.ChangeState(EStateId.ALERTING)
    End Sub


    Public Overrides Sub onConnect()
      _smref.ChangeState(EStateId.ACTIVE)
    End Sub

    Public Overrides Function endCall() As Boolean
      _smref.ChangeState(EStateId.TERMINATED)
      CallProxy.endCall()
      Return MyBase.endCall()
    End Function

  End Class
#End Region

End Namespace
